#!/usr/bin/env sh

PREFIX="/tmp/conjure-school"

if [ ! -d $PREFIX ]; then
  echo "Downloading Conjure into $PREFIX..."
  curl -LJ https://github.com/Olical/conjure/archive/main.zip -o $PREFIX.zip
  unzip -qq $PREFIX.zip -d $PREFIX
  rm $PREFIX.zip
else
  echo "$PREFIX already exists, no need to download."
fi

nvim \
  --cmd "set rtp+=$PREFIX/conjure-main" \
  --cmd "source $PREFIX/conjure-main/plugin/conjure.lua" \
  -c "au VimEnter * ++nested ConjureSchool" &&
  echo "I hope you had a great time! Cleaning up $PREFIX and exiting." &&
  rm -rf $PREFIX
